public class One {
    public int getLongestPalindrome (String s) {
        //中心扩展算法
        int n=s.length();
        int ret=0;
        for (int i = 0; i < n; i++) {//枚举所有的中点
            //当长度为奇数的时候
            int left=i-1,right=i+1;
            while (left>=0&&right<n&&s.charAt(left)==s.charAt(right)){
                left--;
                right++;
            }
            ret=Math.max(ret,right-left-1);
            //当长度为偶数的时候
            left=i;
            right=i+1;
            while (left>=0&&right<n&&s.charAt(left)==s.charAt(right)){
                left--;
                right++;
            }
            ret=Math.max(ret,right-left-1);
        }
        return ret;
    }
}
